package cn.enjoy.rocketmq.controller;

import cn.enjoy.rocketmq.component.MqComponent;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.SneakyThrows;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author K
 * @date 2021-10-31 16:48
 */
@RequestMapping("aliyun")
@RestController
public class AliyunMqController {
    @Resource
    private MqComponent mqComponent;
    @Resource
    private ObjectMapper objectMapper;


    @SneakyThrows
    @PostMapping("hello")
    public void hello(String msg) {
        mqComponent.sendAsyncMessage(objectMapper.writeValueAsBytes(msg), "hello");
    }
}
